package com.nccsjz.pojo;

import java.math.BigDecimal;

import utils.NumberUtils;
/**
 * VoteAnswer类封装了选票答案的内容
 * 
 * @author jason
 *
 */
public class VoteAnswer {

	/** voteAnswerId Long 投票答案编号 */
	private Long voteAnswerId;

	/** content String 投票答案内容 */
	private String content;

	/** clickCount Long 投票数量 */
	private Long clickCount;	

	/** vote　Vote 投票答案所属选票 **/
	private Vote vote;

	public VoteAnswer() {
		super();
		// TODO Auto-generated constructor stub
	}

	public VoteAnswer(Vote vote) {
		this.vote = vote;
	}

	public Long getVoteAnswerId() {
		return voteAnswerId;
	}

	public void setVoteAnswerId(Long voteAnswerId) {
		this.voteAnswerId = voteAnswerId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Long getClickCount() {
		return clickCount;
	}

	public void setClickCount(Long clickCount) {
		this.clickCount = clickCount;
	}	

	public Vote getVote() {
		return vote;
	}

	public void setVote(Vote vote) {
		this.vote = vote;
	}

	/**
	 * getClickPercent方法用于计算答案的投票率
	 * 
	 * @return
	 */
	public double getClickPercent() {
		if (null == vote || null == vote.getAnswers()
				|| vote.getAnswers().size() == 0)
			return 0d;
		long clickSum = vote.getTotalClickCount();		
		double percent = NumberUtils.round(clickCount.longValue()*100d
				/ clickSum, 1);
		return percent;
	}

}
